home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / ham / sattrk31.tgz / sattrack-3.1.tar / SatTrack / src / sattrack / satvect.c < prev   
C/C++ Source or Header  |  1995-03-16  |  6KB  |  136 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*  Title       : satvect.c                                                   */
  4. /*  Author      : Manfred Bester                                              */
  5. /*  Date        : 15Aug93                                                     */
  6. /*  Last change : 15Mar95                                                     */
  7. /*                                                                            */
  8. /*  Synopsis    : Auxiliary math routines for the satellite tracking program  */
  9. /*                'sattrack'.                                                 */
  10. /*                                                                            */
  11. /*                                                                            */
  12. /*  SatTrack is Copyright (c) 1992, 1993, 1994, 1995 by Manfred Bester.       */
  13. /*  All Rights Reserved.                                                      */
  14. /*                                                                            */
  15. /*  Permission to use, copy, and distribute SatTrack and its documentation    */
  16. /*  in its entirety for educational, research and non-profit purposes,        */
  17. /*  without fee, and without a written agreement is hereby granted, provided  */
  18. /*  that the above copyright notice and the following three paragraphs appear */
  19. /*  in all copies. SatTrack may be modified for personal purposes, but        */
  20. /*  modified versions may NOT be distributed without prior consent of the     */
  21. /*  author.                                                                   */
  22. /*                                                                            */
  23. /*  Permission to incorporate this software into commercial products may be   */
  24. /*  obtained from the author, Dr. Manfred Bester, 1636 M. L. King Jr. Way,    */
  25. /*  Berkeley, CA 94709, USA. Note that distributing SatTrack 'bundled' in     */
  26. /*  with ANY product is considered to be a 'commercial purpose'.              */
  27. /*                                                                            */
  28. /*  IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, */
  29. /*  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF   */
  30. /*  THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED  */
  31. /*  OF THE POSSIBILITY OF SUCH DAMAGE.                                        */
  32. /*                                                                            */
  33. /*  THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT      */
  34. /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A   */
  35. /*  PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"      */
  36. /*  BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, */
  37. /*  UPDATES, ENHANCEMENTS, OR MODIFICATIONS.                                  */
  38. /*                                                                            */
  39. /******************************************************************************/
  40.  
  41. #include <stdio.h>
  42. #include <math.h>
  43.  
  44. #ifndef STDLIB
  45. #include <stdlib.h>
  46. #endif
  47.  
  48. #include "satglobalsx.h"
  49. #include "sattrack.h"
  50.  
  51. /******************************************************************************/
  52. /*                                                                            */
  53. /* absol: calculates length (absolute value) of a vector in 3D                */
  54. /*                                                                            */
  55. /******************************************************************************/
  56.  
  57. double absol(absVec)
  58.  
  59. double absVec[3];
  60.  
  61. {
  62.     double absVal;
  63.  
  64.     absVal = sqrt(SQR(absVec[0]) + SQR(absVec[1]) + SQR(absVec[2]));
  65.  
  66.     return(absVal);
  67. }
  68.  
  69. /******************************************************************************/
  70. /*                                                                            */
  71. /* cross: calculates vector product of two vectors in 3D                      */
  72. /*                                                                            */
  73. /*        for right-handed cross products 'vecSign' has to be set to '1'      */
  74. /*                                                                            */
  75. /******************************************************************************/
  76.  
  77. void cross(xVec,yVec,pcrVec,vecSign)
  78.  
  79. double xVec[3], yVec[3], (*pcrVec)[3];
  80. int    vecSign;
  81.  
  82. {
  83.     (*pcrVec)[0] = (xVec[1]*yVec[2] - xVec[2]*yVec[1]) * (double) vecSign;
  84.     (*pcrVec)[1] = (xVec[2]*yVec[0] - xVec[0]*yVec[2]) * (double) vecSign;
  85.     (*pcrVec)[2] = (xVec[0]*yVec[1] - xVec[1]*yVec[0]) * (double) vecSign;
  86.  
  87.     return;
  88.  
  89. /******************************************************************************/
  90. /*                                                                            */
  91. /* multMatVec: multiplies a matrix with a vector in 3D                        */
  92. /*                                                                            */
  93. /******************************************************************************/
  94.  
  95. void multMatVec(amVec,pbmVec,mtx)
  96.  
  97. double amVec[3], (*pbmVec)[3], mtx[3][3];
  98.  
  99. {
  100.     int i;
  101.  
  102.     for (i = 0; i <= 2; i++)
  103.     {
  104.         (*pbmVec)[i] = mtx[i][0]*amVec[0] + 
  105.                        mtx[i][1]*amVec[1] +
  106.                        mtx[i][2]*amVec[2];
  107.     }
  108.  
  109.     return;
  110. }
  111.  
  112. /******************************************************************************/
  113. /*                                                                            */
  114. /* scalar: calculates scalar product of two vectors in 3D                     */
  115. /*                                                                            */
  116. /******************************************************************************/
  117.  
  118. double scalar(asVec,bsVec)
  119.  
  120. double asVec[3], bsVec[3];
  121.  
  122. {
  123.     double scalarProd;
  124.  
  125.     scalarProd = asVec[0]*bsVec[0] + asVec[1]*bsVec[1] + asVec[2]*bsVec[2];
  126.  
  127.     return(scalarProd);
  128. }
  129.  
  130. /******************************************************************************/
  131. /*                                                                            */
  132. /* End of function block satvect.c                                            */
  133. /*                                                                            */
  134. /******************************************************************************/
  135.